from django.urls import path
from . import views

urlpatterns = [
    # 认证相关
    path('login/', views.user_login, name='user_login'),  # POST /api/users/login/
    path('logout/', views.user_logout, name='user_logout'),  # POST /api/users/logout/
    
    # 统计相关
    path('statistics/', views.get_users_statistics, name='users_statistics'),
    
    # 用户管理 - 通用接口
    path('', views.get_all_users, name='all_users'),  # GET /api/users/
    path('all/', views.get_all_users, name='all_users_legacy'),  # 保持向后兼容
    path('create/', views.create_user, name='create_user'),  # POST /api/users/create/
    
    # 单个用户操作
    path('<str:user_id>/', views.get_user_detail, name='user_detail'),  # GET /api/users/{id}/
    path('<str:user_id>/update/', views.update_user, name='update_user'),  # PUT /api/users/{id}/update/
    path('update/<str:user_id>/', views.update_user, name='update_user_legacy'),  # 保持向后兼容
    path('<str:user_id>/status/', views.toggle_user_status, name='toggle_user_status'),  # PATCH /api/users/{id}/status/
    path('toggle-status/<str:user_id>/', views.toggle_user_status, name='toggle_user_status_legacy'),  # 保持向后兼容
    path('<str:user_id>/delete/', views.delete_user, name='delete_user'),  # DELETE /api/users/{id}/delete/
    
    # 按类型获取用户
    path('type/<str:user_type>/', views.get_users_by_type, name='get_users_by_type'),  # GET /api/users/type/{admin|employee|safety}/
    
    # 个人资料管理
    path('<str:user_id>/profile/', views.user_profile_detail, name='user_profile_detail'),  # GET/PUT /api/users/{id}/profile/
    path('<str:user_id>/avatar/', views.upload_user_avatar, name='upload_user_avatar'),  # POST /api/users/{id}/avatar/
    path('<str:user_id>/password/', views.change_user_password, name='change_user_password'),  # POST /api/users/{id}/password/
]
